﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace Milkify.ComponentModel
{
    public class DateTimeValueConverter : IValueConverter
    {
        public string Format { get; set; }

        public DateTimeValueConverter()
        {
        }

        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            DateTime dateTime = (DateTime)value;
            return dateTime.ToString(Format, culture);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return DateTime.ParseExact(value.ToString(), Format, culture);
        }

        #endregion
    }
}
